<template>
	<view class="main-page user-page">
		<view class="user-info">
			<!-- <view class="avatar">
				<u-avatar :src="avatar" size="70"></u-avatar>
			</view>
			<view class="infos">
				<view class="name">
					{{userInfo.nickname}}
				</view>
				<view class="phone">
					{{userInfo.mobile}}
				</view>
			</view> -->
		</view>
		<view class="static-container">
			<view class="items">
				<view class="item">
					<view class="num">{{overview.income_day}}</view>
					<view class="text">今日收入</view>
				</view>
				<view class="item">
					<view class="num">{{overview.income_month}}</view>
					<view class="text">本月收入</view>
				</view>
			</view>
		</view>
		<view class="order-container">
			<view class="items">
				<view class="item" @tap="toUrls('/pages/user/order?tab=1')">
					<view class="num">{{overview.free_car_num}}</view>
					<view class="text">空闲车辆</view>
				</view>
				<view class="item" @tap="toUrls('/pages/user/order?tab=2')">
					<view class="num">{{overview.staff_num}}</view>
					<view class="text">员工数</view>
				</view>
			</view>
		</view>
		<view class="cars-container">
			<view class="cars-container-title">
				<view class="cars-container-title-text">
					空闲车辆
				</view>
			</view>
			<view class="cars-container-items">
				<carList :datas="car_lists"></carList>
			</view>
		</view>
	</view>
</template>

<script>
	import { userOverview, carLists } from '@/common/api.js';
	import carList from '@/components/car_list.vue';
	
	export default {
		components:{
			carList
		},
		data() {
			return {
				overview: {
					free_car_num: 0,
					staff_num: 0,
					income_day: 0,
					income_month: 0
				},
				car_lists: []
			}
		},
		computed: {
			
		},
		onLoad() {
			
		},
		onShow() {
			this.getOverview()
			this.getCarList()
		},
		methods: {
			 toUrls(url){
				 uni.navigateTo({
				 	url: url
				 })
			 },
			 toPhone(){
				 uni.makePhoneCall({
				 	phoneNumber: this.$store.state.$siteConfig.services_phone
				 });
			 },
			 getOverview(){
				 userOverview().then(res => {
					 this.overview = res
				 })
			 },
			 getCarList(){
				 carLists({status: 1}).then(res => {
					this.car_lists = res.list
				 })
			 }
		}
	}
</script>

<style lang="scss">
	.user-page { min-height: 100vh; background-image: url('#{$imgUrl}/images/my-bg2.png'); background-repeat: no-repeat;background-size: 100% auto;}
	.user-info { 
		padding: 130rpx 30rpx 0 30rpx; display: flex; color: #fff; flex-direction: row; align-items: center;
		.infos { 
			padding-left: 20rpx; flex: 1;
			.name { font-weight: bold; font-size: 34rpx; padding-bottom: 20rpx;}
		}
	}
	.order-container {
		background-color: #fff; margin: 50rpx 30rpx 0 30rpx; padding: 20rpx; border-radius: 15rpx;
		.title {
			font-size: 30rpx; font-weight: bold;display: flex; justify-content: space-between; padding-bottom: 20rpx;		
			.more { font-weight: normal; color: #777; font-size: 24rpx;}
		}
		.items { 
			display: flex;
			.item { 
				flex:1; text-align: center; padding-bottom: 10rpx;
				.num { font-size: 42rpx; font-weight: 500; }
				.text { font-size: 26rpx; padding-top:14rpx;}
			}
			.item+.item {
				position: relative;
			}
			.item+.item::before {
				content:" ";display:inline-block;position: absolute; left: 0; top:10%; height: 80%;width: 1px; background-color: #eee;
			}
		}
	}
	.static-container {
		margin: 30rpx 30rpx 0 30rpx; border-radius: 15rpx; color: #fff;
		.items {
			display: flex; justify-content: space-between;
			.item { 
				width: 300rpx; text-align: center; padding-bottom: 10rpx;
				.num { font-size: 42rpx; font-weight: 500; }
				.text { font-size: 26rpx; padding-top:14rpx;}
			}
		}
	}
	.cars-container {
		padding: 30rpx 30rpx;border-radius: 15rpx; border-radius: 15rpx;
		&-title { 
			font-size: 28rpx; font-weight: 600; padding-bottom: 20rpx;
		}
	}
	.menus { 
		background-color: #fff; border-radius: 15rpx; margin: 30rpx;
		.item { 
			display: flex;margin: 0 10rpx; padding: 26rpx 0; 
			.text { flex: 1; font-size: 28rpx;}
			.u-icon { padding: 0 10rpx; }
		}
		.item+.item { border-top: 1px solid #eee; }
	}
</style>
